
<!DOCTYPE HTML>
<html>

<div th:replace="/views/common/adminhead::head(title=${'同城失物招领平台 后台登录'})"></div>

<link rel="stylesheet" href="/admin/css/supersized.css" type="text/css" />

<link rel="stylesheet" href="/admin/scripts/miniui/themes/pure/skin.css" type="text/css" />
<style type="text/css">

    .login_win_later{
        width:320px;
        height:200px;
        margin: auto;
        margin-top: 200px;
    }
    .login_win_later #loginForm table tr{
        height: 40px;
    }
    .login_win_later #loginForm table tr td input{
        height: 30px;
    }
    .ivu-btn {
        display: inline-block;
        margin-bottom: 0;
        font-weight: 400;
        text-align: center;
        vertical-align: middle;
        -ms-touch-action: manipulation;
        touch-action: manipulation;
        cursor: pointer;
        background-image: none;
        border: 1px solid transparent;
        white-space: nowrap;
        line-height: 1.5;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        height: 32px;
        padding: 0 15px;
        font-size: 14px;
        border-radius: 4px;
        -webkit-transition: color .2s linear, background-color .2s linear, border .2s linear, -webkit-box-shadow .2s linear;
        transition: color .2s linear, background-color .2s linear, border .2s linear, -webkit-box-shadow .2s linear;
        transition: color .2s linear, background-color .2s linear, border .2s linear, box-shadow .2s linear;
        transition: color .2s linear, background-color .2s linear, border .2s linear, box-shadow .2s linear, -webkit-box-shadow .2s linear;
        color: #515a6e;
        background-color: #fff;
        border-color: #dcdee2
    }
    .ivu-btn-primary {
        color: #fff;
        background-color: #2d8cf0;
        border-color: #2d8cf0
    }
    .ivu-btn-small {
        height: 24px;
        padding: 0 7px;
        font-size: 14px;
        border-radius: 3px
    }
</style>

<script type="text/javascript">
    var system = {};
    var p = navigator.platform;
    var u = navigator.userAgent;

    system.win = p.indexOf("Win") == 0;
    system.mac = p.indexOf("Mac") == 0;
    system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
    if (!(system.win || system.mac || system.xll)) {

        window.location.href = "/handel-error/refuse-error.html";
    }
</script>
<body >
<div id="loginWindow" class="mini-window login_win_later" title="管理员登录"
     showModal="true" showCloseButton="false">

    <div id="loginForm" style="padding:15px;padding-top:10px;">

            <table >
                <tr>
                    <td style="width:60px;text-align: right;"><label for="userName$text">帐号：</label></td>
                    <td>
                        <input value="admin" id="userName" name="userName" onvalidation="onUserNameValidation" class="mini-textbox" required="true" style="width:160px;"/>
                        <span id="Lcp"></span>
                    </td>
                </tr>
                <tr>
                    <td style="width:60px;text-align: right;"><label for="password$text">密码：</label></td>
                    <td>
                        <input value="admin" id="password" name="password" onvalidation="onPasswordValidation" class="mini-password" requiredErrorText="密码不能为空" required="true" style="width:160px;"/>
                    </td>
                </tr>
                <tr>
                    <td style="width:60px;text-align: right;"><label for="code$text">验证码：</label></td>
                    <td>
                        <input id="code" name="code" onvalidation="onCodeValidation" class="mini-textbox" requiredErrorText="验证码不能为空" required="true" style="width:78px;"/>
                        <img src="/code.do" id="imgcode" onclick="changeCode(this);" alt="看不清，单击更换" style="width:78px;height:30px;cursor:pointer;">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td style="padding-top:5px;">
                        <button type="button" class="ivu-btn ivu-btn-primary" style="width: 80px" id="login">
                            <!----> <!---->
                            <span>登录</span>
                        </button>
                    </td>
                </tr>
            </table>

    </div>

</div>
</body>
</html>
<script type="text/javascript">

    function onLoginClick() {

        setTimeout(function () {


            $.ajax({
                url: "/admin/login.html",
                type: "post",
                data: {
                    userName:$('#userName')[0].value,
                    password:$('#password')[0].value,
                    code:$('#code')[0].value
                },
                success: function (data) {
                    if (data.msg == "codeErr") {
                        alert("验证码错误!");

                    } else if (data.msg == "success") {
                        window.location = "/admin/index.html";

                    } else if (data.msg == "error") {
                        alert("用户名或密码错误!");

                    } else if (data.msg == "lock") {
                        alert("你的账号被冻结!");
                    }
                },
                error: function(e) {
                    alert("网络异常或系统错误!");
                },
                dataType: "json"
            });

        }, 1000);

    }
    $('#login')[0].onclick = onLoginClick;
    function isEmail(s) {
        if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1 || s.length < 12)
            return true;
        else
            return false;
    }

    // 账号
    function onUserNameValidation(e) {
        if (e.isValid) {
            if (isEmail(e.value) == false) {
                e.errorText = "必须输入邮件地址";
                e.isValid = false;
            }
        }
    }

    // 密码
    function onPasswordValidation(e) {
        if (e.isValid) {
            if (e.value.length < 5) {
                e.errorText = "密码不能少于5个字符";
                e.isValid = false;
            }
        }
    }

    // 验证码
    function onCodeValidation(e) {
        if (e.isValid) {
            if (e.value.length != 4) {
                e.errorText = "验证码4位";
                e.isValid = false;
            }
        }
    }

    //更换验证码
    function changeCode(_this) {
        _this.src = "/code.do?t=" + new Date().getTime();
    }

    //支持Enter键登录
    document.onkeydown = function(e){

        if(!e) e = window.event;
        if((e.keyCode || e.which) == 13 && loginenabled){
            onLoginClick(e);
        }
    }

    function setTrue() {
        loginenabled = true;
    }

    var PATH = "${path}";

</script>
<script src="/admin/js/supersized.3.2.7.min.js"></script>
<script src="/admin/js/supersized-init.js"></script>